<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .cell {
            margin: 0;
            padding: 0;
            height: 100px;
            width: 100px;
            background-color: skyblue;
            position: absolute;
        }
    </style>
</head>
<body>
<div class="cell"></div>
</body>
<script>
    function drag(elem) {
        function move(event) {
            var e = event || window.event;
            elem.style.left = e.pageX - elem.inX + 'px';
            elem.style.top = e.pageY - elem.inY + 'px';
        }

        elem.addEventListener('mousedown', function (event) {
            var e = event || window.event;
            this.inX = e.pageX - this.offsetLeft;
            this.inY = e.pageY - this.offsetTop;
            document.addEventListener('mousemove', move);
        });
        elem.addEventListener('mouseup', function () {
            document.removeEventListener('mousemove', move);
        });
    }

    var cell = document.getElementsByClassName('cell')[0];
    drag(cell);
</script>
</html>